package aop.javaDynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class PassTwoDaoDynamic implements InvocationHandler{
private Object passTwoDaoImpl;

	public Object bind(Object passTwoDaoImpl) {
//	super();
	this.passTwoDaoImpl = passTwoDaoImpl;
	return Proxy.newProxyInstance(passTwoDaoImpl.getClass().getClassLoader(),
			passTwoDaoImpl.getClass().getInterfaces(), this);
}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
	
		Object result = null;
		long startTime = System.currentTimeMillis();
		result = ((Method) passTwoDaoImpl).invoke(passTwoDaoImpl, args);
		long endTime = System.currentTimeMillis();
		System.out.println("执行时间" + (endTime - startTime));
		return result;
	}

}
